package cz.muni.fi.pa165.login;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.apache.shiro.realm.jdbc.JdbcRealm;

/**
 *
 * @author shifty
 */
public class SecurityJdbcRealm extends JdbcRealm {
    public SecurityJdbcRealm() {		
        super();

        //get the DataSource that JSecurity's JdbcRealm
        //should use to find the user's password
        //using the provided username
        //see context.xml for this DataSource's properties
        InitialContext initialContext;
        DataSource dataSource;
        try {
            initialContext = new InitialContext();
            dataSource = (DataSource) initialContext.lookup("java:app/jdbc/pa165");
            this.setDataSource(dataSource);
        } catch (NamingException e) {
            e.printStackTrace();
        }
    }

}